package com.ssd.controller.inner;

import cn.hutool.core.bean.BeanUtil;
import com.ssd.api.user.UserApi;
import com.ssd.api.user.dto.UserVo;
import com.ssd.entity.User;
import com.ssd.service.IUserService;
import com.ssd.view.BaseResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * 内容接口-用户
 */
@RestController
@RequestMapping("/inner/user")
public class UserApiController implements UserApi {
    @Resource
    private IUserService userService;

    /**
     * 根据用户id查询用户信息
     * @return
     */
    @Override
    @GetMapping("/{id}")
    @ApiOperation(value = "根据用户id查询用户信息")
    public UserVo findById(@PathVariable("id") Long id) {
        User user = userService.getById(id);
        if (user != null){
            user.setPassword("******");
        }
        UserVo bean = BeanUtil.toBean(user, UserVo.class);
        return bean;
    }
}
